
//声明一个接口    这里的接口与之前说讲 API 接口不一样
interface BaseInfo{
  name: string,
  age: number
}

//男朋友的接口
interface BoyFriend extends BaseInfo{
  //可选属性设置
  car ?: string,
  //只读
  readonly id: number,
  //限制方法
  cook: () => void 
}

let obj: BoyFriend = {
  name: '明磊',
  age: 20,
  car: '雅迪',
  id: 1,
  cook(){
    console.log('我可以做大餐~~~')
  }
}

//员工
interface Staff extends BaseInfo{
  work: () => void
}

//implements 实现
class Person implements BoyFriend, Staff{
  name: string;
  age: number;
  id: number;
  a: number;

  constructor(name: string, age:number, id: number, a: number){
    this.name = name;
    this.age = age;
    this.id = id;
    this.a = a;
  }

  cook(){
    console.log('我可以煮方便面~~');
  }

  work(){
    console.log('我可以干活....');
  }
}


//实例化对象
let p: Person = new Person('xiaohigh', 35, 10, 1);

//调用方法
p.work();
